class Solution:
    def maxConsecutiveAnswers(self, answerKey: str, k: int) -> int:
        t = f = 0
        ans = 0
        left = 0
        for right in range(len(answerKey)):
            if answerKey[right] == "T":
                t += 1
            else:
                f += 1
            # py3 && ~ and
            while t > k and f > k:
                if answerKey[left] == "T":
                    t -= 1
                else:
                    f -= 1
                left += 1
            ans = max(ans, right - left + 1)
        return ans
